package com.huawei.appmarket.service.substance;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AbsListView;
import android.widget.ListAdapter;
import com.huawei.appgallery.foundation.ui.framework.widget.FooterView;
import com.huawei.appgallery.foundation.ui.framework.widget.PullUpListView;
import java.lang.ref.WeakReference;
import o.cij;
import o.ContentManager;
import o.ewm.d;

public class SubstanceListView extends PullUpListView {
    private OnScrollListener ʻ = null;
    private View ॱॱ = null;

    static class c implements Runnable {
        private WeakReference<SubstanceListView> ˏ;

        c(SubstanceListView substanceListView) {
            this.ˏ = new WeakReference(substanceListView);
        }

        public void run() {
            SubstanceListView substanceListView = (SubstanceListView) this.ˏ.get();
            if (substanceListView != null) {
                substanceListView.ॱॱ.requestLayout();
            }
        }
    }

    public SubstanceListView(Context context) {
        super(context);
    }

    public SubstanceListView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public SubstanceListView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    public void setAdapter(ListAdapter listAdapter) {
        ʿ();
        if (this.ॱॱ != null) {
            addFooterView(this.ॱॱ);
            if ((listAdapter instanceof cij) && ॱˋ()) {
                this.ˏ = (cij) listAdapter;
                this.ˋ = new FooterView(getContext());
                addFooterView(this.ˋ);
                if (this.ˏ.hasMore()) {
                    if (this.ॱॱ.getLayoutParams() == null) {
                        this.ॱॱ.setLayoutParams(new LayoutParams(-1, -2));
                    }
                    LayoutParams layoutParams = (LayoutParams) this.ॱॱ.getLayoutParams();
                    layoutParams.height = (int) ContentManager.getInstant().getContext().getResources().getDimension(d.ˊᐝ);
                    this.ॱॱ.setLayoutParams(layoutParams);
                    postDelayed(new c(this), 10);
                    this.ॱॱ.setVisibility(8);
                } else {
                    ˏॱ();
                }
            }
        }
        super.setAdapter(listAdapter);
    }

    public void ʼ() {
    }

    private void ʿ() {
        if (this.ˋ != null) {
            removeFooterView(this.ˋ);
        }
        if (this.ॱॱ != null) {
            removeFooterView(this.ॱॱ);
        }
    }

    public void setOnScrollListener(OnScrollListener onScrollListener) {
        this.ʻ = onScrollListener;
        super.setOnScrollListener(onScrollListener);
    }

    public View ᐝॱ() {
        return this.ॱॱ;
    }

    public void setBottomCardLayout(View view) {
        this.ॱॱ = view;
    }

    public void handleDataChanged() {
        super.handleDataChanged();
        if (!this.ˏ.hasMore() && this.ॱॱ != null) {
            if (this.ॱॱ.getLayoutParams() == null) {
                this.ॱॱ.setLayoutParams(new LayoutParams(-1, -2));
            }
            LayoutParams layoutParams = (LayoutParams) this.ॱॱ.getLayoutParams();
            layoutParams.height = -2;
            this.ॱॱ.setLayoutParams(layoutParams);
            postDelayed(new Runnable(this) {
                final /* synthetic */ SubstanceListView ˏ;

                {
                    this.ˏ = r1;
                }

                public void run() {
                    this.ˏ.ॱॱ.requestLayout();
                }
            }, 10);
            this.ॱॱ.setVisibility(0);
        }
    }

    public void onScroll(AbsListView absListView, int i, int i2, int i3) {
        super.onScroll(absListView, i, i2, i3);
        if (ᐝ() == -1) {
            ॱ(absListView, i, i2, i3);
        }
    }

    private void ॱ(AbsListView absListView, int i, int i2, int i3) {
        if (this.ॱॱ != null && this.ʻ != null) {
            this.ʻ.onScroll(absListView, i, i2, i3);
        }
    }
}
